#include "FIOverviewsDlg.h"
#include "MoneyMarket/MoneyMarketWidget.h"
#include "BondDealMatrix/DlgBondDealMatrix.h"
#include "TreasuryFutures/TreasuryFutures.h"
#include "InterestRateBondIssuance/InterestRateBondIssuance.h"
#include "CreditDebtRanking/CreditDebtRanking.h"
#include <widgets/SDialog.h>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QScrollArea>

namespace
{
	const int m_rateX0 = 30;
	const int m_rateX1 = 46;
	const int m_rateX2 = 24;

	typedef unsigned int UINT;
	const UINT m_widthX0 = 392;
	const UINT m_widthX1 = 580;
	const UINT m_widthX2 = 292;
	const UINT m_heightY0 = 332;
	const UINT m_heightY1 = 254;

	const int nGap = 2;
}

FIOverviewsDlg::FIOverviewsDlg(QWidget* parent)
	: QWidget(parent)
{
	QHBoxLayout* mainLayout = new QHBoxLayout(this);
	mainLayout->setContentsMargins(2, 4, 2, 2);
	mainLayout->setSpacing(nGap);

	//第1列
	QVBoxLayout* col0Layout = new QVBoxLayout();
	col0Layout->setContentsMargins(0, 0, 0, 0);
	col0Layout->setSpacing(nGap);
	m_col0Row0 = new MoneyMarketWidget(this);
	m_col0Row0->setMinimumWidth(m_widthX0);
	col0Layout->addWidget(m_col0Row0);

	//第2列
	QVBoxLayout* col1Layout = new QVBoxLayout();
	col1Layout->setContentsMargins(0, 0, 0, 0);
	col1Layout->setSpacing(nGap);
// 	SDialog* pdlg = new SDialog(this);
// 	{
// 		pdlg->setTitle(tr("债券","Bond"));
// 		QVBoxLayout* layout = qobject_cast<QVBoxLayout*>(pdlg->layout());
// 		if (!layout)return;
// 		layout->addStretch();
// 		pdlg->setLayout(layout);
// 
// 	}
	m_col1Row0 = (QWidget*)(new DlgBondDealMatrix(this));
	//m_col1Row0->setStyleSheet("background-color:pink;");
	m_col1Row0->setMinimumSize(m_widthX1, m_heightY0);
	col1Layout->addWidget(m_col1Row0, 1);
	m_col1Row1 = (QWidget*)(new TreasuryFutures(this));
	m_col1Row1->setMinimumSize(m_widthX1, m_heightY1);
	col1Layout->addWidget(m_col1Row1, 1);

	//第3列
	QVBoxLayout* col2Layout = new QVBoxLayout();
	col2Layout->setContentsMargins(0, 0, 0, 0);
	col2Layout->setSpacing(nGap);
	m_col2Row0 = new InterestRateBondIssuance(this);
	m_col2Row0->setMinimumSize(m_widthX2, m_heightY0);
	col2Layout->addWidget(m_col2Row0, 1);
	m_col2Row1 = new CreditDebtRanking(this);
	m_col2Row1->setMinimumSize(m_widthX2, m_heightY1);
	col2Layout->addWidget(m_col2Row1, 1);

	QHBoxLayout* subWidgetlayout = new QHBoxLayout();
	subWidgetlayout->setContentsMargins(0, 0, 0, 0);
	subWidgetlayout->setSpacing(nGap);
	subWidgetlayout->addLayout(col0Layout, m_rateX0);
	subWidgetlayout->addLayout(col1Layout, m_rateX1);
	subWidgetlayout->addLayout(col2Layout, m_rateX2);
	QWidget* subWidget = new QWidget(this);
	subWidget->setLayout(subWidgetlayout);

	m_scrollwnd = new QScrollArea(this);
	m_scrollwnd->setContentsMargins(0, 0, 0, 0);
	m_scrollwnd->setFrameShape(QFrame::NoFrame);
	m_scrollwnd->setWidgetResizable(true);
	m_scrollwnd->setWidget(subWidget);
	mainLayout->addWidget(m_scrollwnd);
}
